<?php
	//$tribe_id
		$subject_db='phome_jat_tribe_subject';
		$p=$_REQUEST['p'];
		$is_good=$_REQUEST['gd'];
		$whArr=array('tribe_id'=>$tribe_id);
		if($is_good){
			$whArr['is_good']='1';
		}

		$nums=DbTouch($subject_db,$whArr,"count(*) as total");
		$page=new page_obj($p,array("itemnum"=>10,"border"=>4,"row_count"=>$nums['total']));
		$limit_str=$page->get_limit_str();
		$subject_list=DbTouchAll($subject_db,$whArr,'*',' order by  is_top desc,time desc  '.$limit_str);
		$page_list=$page->build_html_link("p");
?>
<style>
	.ipt_box{width:100%;}
	.big-box{height:120px;}
	.current_subject{color:#eee;background:#;}
</style>
<ol id="dh">
	<li><a href="<?=$public_r[newsurl]?>tribe/detail/?id=<?=$tribe_id?>">部落首页</a></li>
	<li><a href="<?=$public_r[newsurl]?>tribe/detail/?id=<?=$tribe_id?>&m=subject" class="change">部落讨论</a></li>
	<li><a href="<?=$public_r[newsurl]?>tribe/detail/?id=<?=$tribe_id?>&m=act">部落活动</a></li>
	<li><a href="<?=$public_r[newsurl]?>tribe/detail/?id=<?=$tribe_id?>&m=pho">部落相册</a></li>
</ol>
 <span class="clear"></span> 
<div id="Topic">
	<h3>
		<span><a href="<?=$public_r[newsurl]?>tribe/detail/?id=<?=$tribe_id?>&m=subject" <?php echo $is_good==1?'':'class="current_subject"' ?>>全部话题</a></span>
		<span><a href="<?=$public_r[newsurl]?>tribe/detail/?id=<?=$tribe_id?>&m=subject&gd=1" <?php echo $is_good==1?'class="current_subject"':'' ?>>查看精华</a></span> 
		部落话题 
</h3>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<th scope="col">话题</th>
		<th scope="col">作者</th>
		<th scope="col">回应</th>
		<th scope="col">最后回应</th>
	  </tr>
	  <?php if($subject_list){
		  foreach($subject_list as $key=>$val){
			  $U=getUserInfo($val['uid']);
		  ?>
	  <tr>
		<td><a href="<?=$public_r[newsurl]?>tribe/detail/?m=ss&id=<?=$tribe_id?>&sid=<?=$val[id]?>"><?php if($val['is_top']){?><span style='color:#EF800A;padding:0px 5px;'>[置顶]</span><?php }?><?=$val['title']?><?php if($val[is_good]){?><img src='<?=$public_r['newsurl']?>images/is_good.gif' height='16'/><?php }?></a></td>
		<td><a href='<?=$public_r[newsurl]?>e/member/sp/?uid=<?=$U['userid']?>'><?=$U['nickname']?></a></td>
		<td><?=$val['reply_num']?></td>
		<td><?=date('m-d H-i-s',$val['last_reply_time'])?></td>
	  </tr>
	 <?php 
		  }	  
		  }else{
			  ?>
	  <tr>
		<td colspan='4'><div class='no-data'>暂时无相关主题！</div></td>
	  </tr>
	 <?php }?>	  
	</table>	
	<div class="page"><?=$page_list?>
	 
	</div>
	
	<p><strong><a href="#" target="_blank">发表话题</a></strong> <span>(只有加入圈子后才能发表话题)</span></p>
	<div>
	<form action='<?=$public_r['newsurl']?>e/o/' method='post' id='pub_subject'/>
	<input type='hidden' name='enews' value='add_tribe_word' />	
	<input type='hidden' name='tid' value='<?=$tribe_id?>' />
		<table>
			<tr><th>标题：</th><td><input type='input' name='title' class='title ipt_box' /></td></tr>
			<tr><th>内容：</th><td><textarea class='ipt_box big-box content' name='content'></textarea></td></tr>
			<tr><td colspan='2'><input type='submit' class='ok_submit' value='发表话题'/></td></tr>
		</table>
	</form>
	<script>
		$("#pub_subject").submit(function(){
			var title=$(this).find('.title').val();
			var content=$(this).find('.content').val();
			if(!title){
				alert('标题不能为空！');
				$(this).find('.title').focus();
				return false;
			}
			if(title.length<5){
				alert('标题必须为长度不能小于5个字');
				$(this).find('.title').focus();
				return false;
			}
			if(title.length>200){
				alert('标题必须为长度不能大于200个字');
				$(this).find('.title').focus();
				return false;
			}
			if(!content){
				alert('内容不能为空！');
				$(this).find('.content').focus();
				return false;
			}
			if(content.length<20){
				alert('内容长度不能小于20个字！');
				$(this).find('.content').focus();
				return false;
			}
			return true;
		});
	</script>
	</div>
</div>